package com.fenrirtec.aepp.portal.action;

import org.apache.struts2.dispatcher.SessionMap;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.fenrirtec.aepp.portal.common.action.CommonAction;

public class LogoutAction extends CommonAction {

	private static final long serialVersionUID = 1L;

	private static final Logger logger = LoggerFactory.getLogger(LogoutAction.class);
	
    private String prePage;

    public String getPrePage() {
        return prePage;
    }

    public void setPrePage(String prePage) {
        this.prePage = prePage;
    }

	public String logout() {
		try {
			if (logger.isInfoEnabled()) {
				logger.info("[LogoutAction#logout] start.");
			}
			if (getSession() != null) {
			    prePage = (String) getSession().get("prePage");
				((SessionMap<String, Object>) getSession()).invalidate();
				getSession().put("prePage", prePage);
			}
		} finally {
			if (logger.isInfoEnabled()) {
				logger.info("[LogoutAction#logout] finish.");
			}
		}
		return SUCCESS;
	}
}
